package com.zz.cinema.domain;

import java.util.HashSet;
import java.util.Set;
import java.util.UUID;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name = "TS_MOVIE")
public class TS_Movie {

	/**
	 * create sequence SEQ_TS_MOVIE minvalue 50000000 maxvalue 59999999 start
	 * with 50000000 increment by 1 cache 20;
	 */
	@Id
	@GeneratedValue(generator = "sequenceGenerator_TS_MOVIE", strategy = GenerationType.SEQUENCE)
	@SequenceGenerator(name = "sequenceGenerator_TS_MOVIE", sequenceName = "SEQ_TS_MOVIE", initialValue = 50000000, allocationSize = 1)
	private int movieId;

	private String mCode;

	private String mName;

	private String mType;

	private String mArea;

	private int mDuration; // unit MINUTE

	private String mDesc;

	private double star;

	private String image;

	private String director;

	private String actor;

	@OneToMany(mappedBy = "movie", targetEntity = TS_ItemON.class, fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	private Set<TS_ItemON> itemONs = new HashSet<>();

	public TS_Movie() {
		super();
		this.mCode = UUID.randomUUID().toString().toUpperCase().substring(0, 8);
	}

	public TS_Movie(String mName, String mType, String mArea, int mDuration, String mDesc, double star, String image,
			String director, String actor) {
		super();
		this.mCode = UUID.randomUUID().toString().toUpperCase().substring(0, 8);
		this.mName = mName;
		this.mType = mType;
		this.setmArea(mArea);
		this.mDuration = mDuration;
		this.mDesc = mDesc;
		this.star = star;
		this.image = image;
		this.director = director;
		this.actor = actor;
	}

	public int getMovieId() {
		return movieId;
	}

	public void setMovieId(int movieId) {
		this.movieId = movieId;
	}

	public String getMovieCode() {
		return mCode;
	}

	public void setMovieCode(String mCode) {
		this.mCode = mCode;
	}

	public String getmCode() {
		return mCode;
	}

	public void setmCode(String mCode) {
		this.mCode = mCode;
	}

	public String getmName() {
		return mName;
	}

	public void setmName(String mName) {
		this.mName = mName;
	}

	public String getmType() {
		return mType;
	}

	public void setmType(String mType) {
		this.mType = mType;
	}

	public int getmDuration() {
		return mDuration;
	}

	public void setmDuration(int mDuration) {
		this.mDuration = mDuration;
	}

	public String getmDesc() {
		return mDesc;
	}

	public void setmDesc(String mDesc) {
		this.mDesc = mDesc;
	}

	public double getStar() {
		return star;
	}

	public void setStar(double star) {
		this.star = star;
	}

	public String getImage() {
		return image;
	}

	public void setImage(String image) {
		this.image = image;
	}

	public String getDirector() {
		return director;
	}

	public void setDirector(String director) {
		this.director = director;
	}

	public String getActor() {
		return actor;
	}

	public void setActors(String actor) {
		this.actor = actor;
	}

	public String getmArea() {
		return mArea;
	}

	public void setmArea(String mArea) {
		this.mArea = mArea;
	}

	@Override
	public String toString() {
		return "TS_Movie [movieId=" + movieId + ", mCode=" + mCode + ", mName=" + mName + ", mType=" + mType
				+ ", mArea=" + mArea + ", mDuration=" + mDuration + ", mDesc=" + mDesc + ", star=" + star + ", image="
				+ image + ", director=" + director + ", actor=" + actor + ", itemONs=" + itemONs + "]";
	}

}
